package com.pat.jrgwt.client;

import java.util.Date;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Grid;

public class PerformanceInPercent extends Composite
{

    private static PerformanceInPercentUiBinder uiBinder = GWT
            .create(PerformanceInPercentUiBinder.class);

    interface PerformanceInPercentUiBinder extends
            UiBinder<Widget, PerformanceInPercent>
    {
    }

    public PerformanceInPercent()
    {
        initWidget(uiBinder.createAndBindUi(this));
        FormatGrid();
    }
    
    protected void FormatGrid()
    {
        pipGrid.resize(10, 14);
        pipGrid.setCellSpacing(0);
        pipGrid.setBorderWidth(1);
        
        String[] arHeader = new String[14];
        int pos = 0;
        arHeader[pos++] = "Year";
        arHeader[pos++] = "Jan";
        arHeader[pos++] = "Feb";
        arHeader[pos++] = "Mar";
        arHeader[pos++] = "Apr";
        arHeader[pos++] = "May";
        arHeader[pos++] = "Jun";
        arHeader[pos++] = "Jul";
        arHeader[pos++] = "Aug";
        arHeader[pos++] = "Sept";
        arHeader[pos++] = "Oct";
        arHeader[pos++] = "Nov";
        arHeader[pos++] = "Dec";
        arHeader[pos++] = "Year";
        
        for( int i = 0; i < pipGrid.getColumnCount(); i++ )
        {
            pipGrid.setText(0, i, arHeader[i]);
        }
        
        Date date = new Date();
        for( int i = 1; i < pipGrid.getRowCount(); i++ )
        {
            pipGrid.setText(i, 0, "" + (date.getYear() + 1901 - i));
        }
        
        arHeader = new String[9];
        pos = 0;
        arHeader[pos++] = "23.56";
        arHeader[pos++] = "-21.63";
        arHeader[pos++] = "25.57";
        arHeader[pos++] = "-4.45";
        arHeader[pos++] = "23.92";
        arHeader[pos++] = "7.41";
        arHeader[pos++] = "32.21";
        arHeader[pos++] = "91.26";
        arHeader[pos++] = "17.93";

        for( int i = 0; i < arHeader.length; i++ )
        {
            pipGrid.setText(i + 1, pipGrid.getColumnCount() - 1, arHeader[i]);
        }

    }

    @UiField Grid pipGrid;

    public PerformanceInPercent(String firstName)
    {
        initWidget(uiBinder.createAndBindUi(this));
    }

}
